<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta content="Apache Forrest" name="Generator">
<meta name="Forrest-version" content="0.8">
<meta name="Forrest-skin-name" content="pelt">
<title>SVG 1.2 support</title>
<link type="text/css" href="../skin/basic.css" rel="stylesheet">
<link media="screen" type="text/css" href="../skin/screen.css" rel="stylesheet">
<link media="print" type="text/css" href="../skin/print.css" rel="stylesheet">
<link type="text/css" href="../skin/profile.css" rel="stylesheet">
<script src="../skin/getBlank.js" language="javascript" type="text/javascript"></script><script src="../skin/getMenu.js" language="javascript" type="text/javascript"></script><script src="../skin/fontsize.js" language="javascript" type="text/javascript"></script>
<link rel="shortcut icon" href="../">
</head>
<body onload="init()">
<script type="text/javascript">ndeSetTextSize();</script>
<div id="top">
<!--+
    |breadtrail
    +-->
<div class="breadtrail">
<a href="http://www.apache.org/">apache</a> &gt; <a href="http://xml.apache.org/">xml</a> &gt; <a href="http://xmlgraphics.apache.org/">graphics</a><script src="../skin/breadcrumbs.js" language="JavaScript" type="text/javascript"></script>
</div>
<!--+
    |header
    +-->
<div class="header">
<!--+
    |start group logo
    +-->
<div class="grouplogo">
<a href="http://xmlgraphics.apache.org/"><img class="logoImage" alt="Apache XML Graphics" src="../images/group-logo.png" title="Apache XML Graphics"></a>
</div>
<!--+
    |end group logo
    +-->
<!--+
    |start Project Logo
    +-->
<div class="projectlogoA1">
<a href="http://xmlgraphics.apache.org/batik/"><img class="logoImage" alt="Apache Batik" src="../images/batik.png" title="Apache Batik"></a>
</div>
<!--+
    |end Project Logo
    +-->
<!--+
    |start Tabs
    +-->
<ul id="tabs">
<li>
<a class="unselected" href="../index.html">Home</a>
</li>
<li>
<a class="unselected" href="../tools/index.html">Tools and applications</a>
</li>
<li>
<a class="unselected" href="../using/index.html">Using Batik</a>
</li>
<li class="current">
<a class="selected" href="../dev/index.html">Development</a>
</li>
</ul>
<!--+
    |end Tabs
    +-->
</div>
</div>
<div id="main">
<div id="publishedStrip">
<!--+
    |start Subtabs
    +-->
<div id="level2tabs"></div>
<!--+
    |end Endtabs
    +-->
<script type="text/javascript"><!--
document.write("Last Published: " + document.lastModified);
//  --></script>
</div>
<!--+
    |breadtrail
    +-->
<div class="breadtrail">

             &nbsp;
           </div>
<!--+
    |start Menu, mainarea
    +-->
<!--+
    |start Menu
    +-->
<div id="menu">
<div onclick="SwitchMenu('menu_selected_1.1', '../skin/')" id="menu_selected_1.1Title" class="menutitle" style="background-image: url('../skin/images/chapter_open.gif');">Development</div>
<div id="menu_selected_1.1" class="selectedmenuitemgroup" style="display: block;">
<div class="menuitem">
<a href="../dev/index.html">Index</a>
</div>
<div class="menuitem">
<a href="../dev/branches.html">Branches</a>
</div>
<div class="menupage">
<div class="menupagetitle">SVG 1.2 support</div>
</div>
<div class="menuitem">
<a href="../dev/test.html">Test infrastructure</a>
</div>
</div>
<div id="credit"></div>
<div id="roundbottom">
<img style="display: none" class="corner" height="15" width="15" alt="" src="../skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
<!--+
  |alternative credits
  +-->
<div id="credit2">
<a href="http://eu.apachecon.com/"><img border="0" title="ApacheCon Europe 2008" alt="ApacheCon Europe 2008 - logo" src="http://apache.org/ads/ApacheCon/2008-europe-125x125.png" style="width: 125px;height: 125px;"></a>
</div>
</div>
<!--+
    |end Menu
    +-->
<!--+
    |start content
    +-->
<div id="content">
<h1>SVG 1.2 support</h1>
<div id="minitoc-area">
<ul class="minitoc">
<li>
<a href="#dom3">DOM Level 3</a>
</li>
<li>
<a href="#sxbl">XML Binding Language for SVG (sXBL)</a>
</li>
<li>
<a href="#flowtext">Flowing text and graphics</a>
</li>
<li>
<a href="#other">Other SVG 1.2 features</a>
</li>
</ul>
</div>
    
<p>
      This page details information atbout Batik&rsquo;s implementation of
      features from SVG 1.2, <a class="external" href="http://www.w3.org/TR/SVGMobile12/">Tiny</a> and
      <a class="external" href="http://www.w3.org/TR/SVG12/">Full</a>.  Note that the information on
      this page is based on the code in the Subversion repository
      trunk.
    </p>

    
<a name="N1001C"></a><a name="dom3"></a>
<h2 class="boxed">DOM Level 3</h2>
<div class="section">
<p>
        DOM Level 3 <a class="external" href="http://www.w3.org/TR/DOM-Level-3-Core/">Core</a>,
        <a class="external" href="http://www.w3.org/TR/DOM-Level-3-Events/">Events</a> and <a class="external" href="http://www.w3.org/TR/DOM-Level-3-XPath/">XPath</a>
        are all supported.  These features are available regardless of whether
        the document has <span class="codefrag">version="1.1"</span> or
        <span class="codefrag">version="1.2"</span> set on the root <span class="codefrag">svg</span> element.
      </p>
<p>
        There are a few issues with the DOM Level 3 Core implementation:
      </p>
<ol>
        
<li>
          The <span class="codefrag">Document.compareDocumentPosition</span> method does not give
          the correct result when used on DTD notation or entity nodes in the
          document.
        </li>
        
<li>
          
<span class="codefrag">Node.renameNode</span> always creates a new node and replaces
          the old node with it.  This is technically allowed, but sub-optimal.
        </li>
        
<li>
          XML Schema information is never used.  Batik does not implement XML
          Schema, so any methods or attributes that would utilise or expose
          schema information (such as the <span class="codefrag">schemaTypeInfo</span> attribute
          on the <span class="codefrag">Attr</span> and <span class="codefrag">Element</span> interfaces) do not
          do so.
        </li>
        
<li>
          
<span class="codefrag">Document.normalizeDocument</span> ignores the
          <span class="codefrag">"entities"</span> parameter in the document&rsquo;s
          <span class="codefrag">DOMConfiguration</span>.
        </li>
      
</ol>
<a name="N10064"></a><a name="dom3java"></a>
<h3 class="boxed">Using DOM Level 3 functionality from Java</h3>
<p>
          JREs before 1.5 include the DOM Level 2 interfaces and this can cause
          problems when trying to use the DOM Level 3 versions of these same interface
          files (<span class="codefrag">org.w3c.dom.*</span>).  Though the concrete Batik DOM
          classes implement the DOM Level 3 functionality, you won&rsquo;t be able to access
          those methods through the <span class="codefrag">org.w3c.dom</span> interfaces on these
          earlier JREs.
        </p>
<p>
          There are two ways to overcome this problem. The first
          is to install the DOM Level 3 interfaces using the
          <a class="external" href="http://java.sun.com/j2se/1.4.2/docs/guide/standards/">Endorsed
            Standards Override Mechanism</a>. Copy the file
          <span class="codefrag">lib/xml-apis-ext.jar</span> into the endorsed standards override
          directory and the DOM Level 3 interfaces will be visible. You can then write
          code against them (for example, call <span class="codefrag">Document.renameNode</span>
          directly).  However, this will mean that other people cannot run or
          compile your code unless they have JRE 1.5 or later, or they have also
          installed the <span class="codefrag">xml-apis-ext.jar</span> in the same way.
        </p>
<p>
          The second method, which requires less messing about with the JRE, is
          to cast your DOM objects to the concrete Batik DOM objects and call
          your DOM Level 3 methods directly on them. The Batik DOM classes are in the
          <span class="codefrag">org.apache.batik.dom</span> package. The classes named
          <span class="codefrag">Abstract*</span> implement the DOM interfaces, and also contain
          the DOM Level 3 methods. The advantage of this method is that for your code
          to compile and run in others&rsquo; environments, they need not install any
          jars with the endorsed standards overrides.
        </p>
<p>
          Here is an example of using the second method to get access to DOM
          Level 3 specific methods:
        </p>
<pre class="code">import org.apache.batik.dom.AbstractDocument;
import org.apache.batik.dom.svg.SVGDOMImplementation;

import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class C {
    public void f() {
        // Create a new SVG document
        DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
        Document doc = impl.createDocument("http://www.w3.org/2000/svg", "svg", null);

        // Create a 'g' element and append it to the root 'svg' element
        Element e = doc.createElementNS("http://www.w3.org/2000/svg", "g");
        doc.getDocumentElement().appendChild(e);

        // Cast the document object to org.apache.batik.dom.AbstractDocument,
        // so that DOM 3 methods will be guaranteed to be visible
        <strong>AbstractDocument document = (AbstractDocument) doc;</strong>

        // Now a DOM 3 method can be used
        <strong>document.renameNode(e, "http://www.w3.org/2000/svg", "text");</strong>
    }
}</pre>
<p>
          For cases where the DOM Level 3 versions of these interfaces contain
          constants that you wish to use, the constants have been copied into
          the Batik DOM classes. For example:
        </p>
<pre class="code">import org.apache.batik.dom.AbstractNode;
import org.apache.batik.dom.svg.SVGDOMImplementation;

import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class C {
    public void f() {
        // Create a new SVG document
        DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
        Document doc = impl.createDocument("http://www.w3.org/2000/svg", "svg", null);

        // Create a 'g' element and append it to the root 'svg' element
        Element svg = doc.getDocumentElement();
        Element e = doc.createElementNS("http://www.w3.org/2000/svg", "g");
        svg.appendChild(e);

        AbstractNode n1 = (AbstractNode) svg;
        AbstractNode n2 = (AbstractNode) e;
        int position = n1.compareDocumentPosition(n2);
        if (position == <strong>AbstractNode.DOCUMENT_POSITION_PRECEDING</strong>
                      | <strong>AbstractNode.DOCUMENT_POSITION_CONTAINS</strong>) {
            System.out.println("The svg element contains the g element.");
        } else {
            System.out.println("Something is wrong!");
        }
    }
}</pre>
<p>
          Note that using these org.apache.batik.dom interfaces is only needed
          for the DOM Level 3 Core and Events interfaces. There were no earlier
          versions of the DOM XPath interfaces to conflict with, so these can be
          used directly (<span class="codefrag">org.w3c.dom.xpath</span>).
        </p>
<p>
          Of course, none of this matters if you are just using the DOM 3
          functionality in ECMAScript, as the matter of interfaces is hidden
          from the scripting environment.
        </p>
</div>

    
<a name="N100B1"></a><a name="sxbl"></a>
<h2 class="boxed">XML Binding Language for SVG (sXBL)</h2>
<div class="section">
<p>
        sXBL is supported in documents with <span class="codefrag">version="1.2"</span>.  However,
        the following issues exist:
      </p>
<ol>
        
<li>
          sXBL cannot be used for
          <a class="external" href="http://www.w3.org/TR/2004/WD-SVG12-20041027/binding.html#sXBL-bindings-for-svg">SVG
            resources</a> or
          <a class="external" href="http://www.w3.org/TR/2004/WD-SVG12-20041027/binding.html#sXBL-bindings-for-visual-effects">visual
            effects</a>.
        </li>
        
<li>
          The <span class="codefrag">traitDef</span> element is not implemented.
        </li>
        
<li>
          The <a class="external" href="http://www.w3.org/TR/sXBL/#shadow0">handling of CSS</a>
          is probably not quite correct.
        </li>
      
</ol>
<p>
        Two content selector languages are supported: XPath 1.0 Patterns and the
        drastically reduced XPath subset. XPath Patterns is the default
        language. To change the language used to the XPath subset, put an
        attribute <span class="codefrag">batik:selectorLanguage="XPathSubset"</span> on the
        <span class="codefrag">xbl:content</span> element or on the <span class="codefrag">svg</span> document
        element. (The <span class="codefrag">batik</span> extension namespace prefix should be
        declared with
        <span class="codefrag">xmlns:batik="http://xml.apache.org/batik/ext"</span>.)
      </p>
<p>
        Note that sXBL is likely to be dropped in favor of
        <a class="external" href="http://www.w3.org/TR/xbl2">XBL 2.0</a> in
        <a class="external" href="http://www.w3.org/TR/SVG12/">SVG 1.2 Full</a>.
      </p>
</div>

    
<a name="N100F6"></a><a name="flowtext"></a>
<h2 class="boxed">Flowing text and graphics</h2>
<div class="section">
<p>
        The <span class="codefrag">flowRoot</span>, <span class="codefrag">flowRegion</span>,
        <span class="codefrag">flowDiv</span>, <span class="codefrag">flowPara</span>, <span class="codefrag">flowSpan</span>,
        <span class="codefrag">flowRegionBreak</span> and <span class="codefrag">flowLine</span> elements
        from <a class="external" href="http://www.w3.org/TR/SVG12/">SVG 1.2 Full</a>&rsquo;s
        <a class="external" href="http://www.w3.org/TR/2004/WD-SVG12-20041027/flow.html">Flowing
          Text and Graphics</a> chapter are supported in documents with
        <span class="codefrag">version="1.2"</span>.
      </p>
<p>
        The more recent <a class="external" href="http://www.w3.org/TR/SVGMobile12/">SVG 1.2 Tiny</a> draft specifies
        a different syntax for (a more restricted version of) flowing text,
        and the full flowing text syntax is therefore likely to change.
      </p>
</div>

    
<a name="N10127"></a><a name="other"></a>
<h2 class="boxed">Other SVG 1.2 features</h2>
<div class="section">
<p>
        The following other features from SVG 1.2 are supported:
      </p>
<ul>
        
<li>
          the <a class="external" href="http://www.w3.org/TR/SVGMobile12/painting.html#SolidColorElement"><span class="codefrag">solidColor</span>
            paint server element,</a>
        
</li>
        
<li>
          the <span class="codefrag">multiImage</span>, <span class="codefrag">subImageRef</span> and
          <span class="codefrag">subImage</span> elements for
          <a class="external" href="http://www.w3.org/TR/2004/WD-SVG12-20041027/media.html#multires">Alternate
            content based on display resolutions</a>,
        </li>
        
<li>
          the XML Events
          <a class="external" href="http://www.w3.org/TR/SVGMobile12/script.html#HandlerElement"><span class="codefrag">handler</span>
            element</a>,
        </li>
        
<li>
          self-contained
          <a class="external" href="http://www.w3.org/TR/2004/WD-SVG12-20041027/nonvisual.html#external-references">resource
            documents</a>,
        </li>
        
<li>
          the mouse
          <a class="external" href="http://www.w3.org/TR/2004/WD-SVG12-20041027/dom.html#wheelevent">wheel
            event</a> (which is likely to be superseded by a similar event
          developed by the W3C WebAPI WG),
        </li>
        
<li>
          the
          <a class="external" href="http://www.w3.org/TR/2004/WD-SVG12-20041027/dom.html#shapemod">ShapeChange
            and RenderedBBoxChange events</a> (though the
          <span class="codefrag">boundingBox</span> attribute of the RenderedBBoxChange event is not
          used), and
        </li>
        
<li>
          the <span class="codefrag">startMouseCapture</span> and <span class="codefrag">stopMouseCapture</span>
          methods on the
          <a class="external" href="http://www.w3.org/TR/2004/WD-SVG12-20041027/api.html#GlobalObject">global
            object</a>.
        </li>
      
</ul>
</div>
  
</div>
<!--+
    |end content
    +-->
<div class="clearboth">&nbsp;</div>
</div>
<div id="footer">
<!--+
    |start bottomstrip
    +-->
<div class="lastmodified">
<script type="text/javascript"><!--
document.write("Last Published: " + document.lastModified);
//  --></script>
</div>
<div class="copyright">
        Copyright &copy;
         2000&ndash;2008 <a href="http://www.apache.org/licenses/">The Apache Software Foundation.</a>
</div>
<!--+
    |end bottomstrip
    +-->
</div>
</body>
</html>
